﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Wicresoft.EKA.NRemedy.Linq
{
    public static class MemberInfoExtensions
    {
        internal static ARFieldAttribute GetARFieldAttribute(this System.Reflection.MemberInfo member)
        {
            object[] attrs = member.GetCustomAttributes(typeof(ARFieldAttribute), true);
            if (attrs.Length > 1)
                throw new CustomAttributeFormatException(
                    string.Format("Mutiple ARFieldAttribute is found on Property : {0}.", member.Name));
            if (attrs.Length == 0)
                throw new CustomAttributeFormatException(
                    string.Format("No ARFieldAttribute is found on Property : {0}.", member.Name));
            return (ARFieldAttribute)attrs.First();
        }
    }
}
